package payment.enums;

import payment.constant.Constants;

/**
 * 余额、红包、优惠券，代金券等
 */
public enum PayWayEnum {
    BALANCE("余额", Constants.BALANCE),
    RED_ENVELOPE("红包", Constants.RED_ENVELOPE),
    COUPONS("优惠券",Constants.COUPONS),
    VOUCHERS("代金券",Constants.VOUCHERS),
    OTHER("其他",Constants.VOUCHERS);

    private String name;

    private String value;

    PayWayEnum(String name, String code) {
        this.name = name;
        this.value = code;
    }

    public static PayWayEnum matchByValue(String value) {
        for (PayWayEnum item : PayWayEnum.values()) {
            if (item.value.equals(value)) {
                return item;
            }
        }
        return OTHER;
    }

    public static PayWayEnum matchByName(String name) {
        for (PayWayEnum item : PayWayEnum.values()) {
            if (item.name.equals(name)) {
                return item;
            }
        }
        return OTHER;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}